package com.Sdebruijn.curriculumvitae;

import android.os.Bundle;
import android.view.View.OnClickListener;

import com.Sdebruijn.curriculumvitae.fragments.EducationDataFragment;
import com.Sdebruijn.curriculumvitae.fragments.PersonFragment;
import com.Sdebruijn.curriculumvitae.fragments.WorkDataFragment;
import com.Sdebruijn.curriculumvitae.swipey.SwipeyTabsAdapter;

/**
 * Main entry point of the app. Holds the swipey tabs for respectively Education
 * - Persona - Work. Further not much more then a simple wrapper
 * 
 * @author Stefan de Bruijn
 */
public class MainActivity extends BaseActivity implements OnClickListener {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		fillData();
	}

	/**
	 * Builds up the visible data from this Activity. Will initiate the
	 * ViewPager and it's Fragments.
	 */
	private void fillData() {

		String[] titles = getResources().getStringArray(R.array.swipeyTabNames);

		Bundle educationBundle = new Bundle();
		educationBundle.putInt(EXTRA_INDEX, 0);
		mPagerAdapter.addTab(EducationDataFragment.class, educationBundle);

		Bundle personalBundle = new Bundle();
		personalBundle.putInt(EXTRA_INDEX, 1);
		mPagerAdapter.addTab(PersonFragment.class, personalBundle);

		Bundle workBundle = new Bundle();
		workBundle.putInt(EXTRA_INDEX, 2);
		mPagerAdapter.addTab(WorkDataFragment.class, workBundle);

		mSwipeyTabsAdapter = new SwipeyTabsAdapter(this, titles, mPager);
		mSwipeyTabs.setAdapter(mSwipeyTabsAdapter);

		// Make the PageViewer start out in the middle
		onPageSelected(1);
		mPager.setAdapter(mPagerAdapter);
		mPager.setCurrentItem(1);
	}

}
